﻿using J.Status.Application.Command.BookingCommand;
using J.StatusModel;
using J.StatusRepository.Interface;
using MediatR;

namespace J.Status.Application.Handler.BookingHandler
{
    public class BookingGetCommandHandler : IRequestHandler<BookingGetCommand, List<BookingModel>>
    {
        public IBookingRepository _IBookingRepository;
        public BookingGetCommandHandler(IBookingRepository bookingRepository)
        {
            _IBookingRepository= bookingRepository;
        }

        public async Task<List<BookingModel>> Handle(BookingGetCommand request, CancellationToken cancellationToken)
        {
            
           var res=from x in await _IBookingRepository.GetAllAsync()
                   where(string.IsNullOrEmpty(request.BookingeName)||  x.BookingName.Contains(request.BookingeName))
                   select x;
            return res.ToList();
        }
    }
}
